import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'
import dateOpt from '@/biz/option/date.js'
import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import dt from '@dt/dt'

let _this = null;

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [{
      title: '序号',
      type: 'index',
      width: 70,
      align: 'center',
    }, {
      title: '所属产品',
      field: 'productName',
      minWidth: 150,
    },
    {
      title: '房源名称',
      field: 'roomName',
      minWidth: 150,
      header: {
        filter: houseOpt.createRoom({
          key: 'roomId',
          title: '房源名称'
        })
      }
    },
    {
      minWidth: 130,
      title: '订单类型',
      field: 'orderType',
    },
    {
      field: 'orderAmount',
      minWidth: 150,
      title: '订单总价(元)',
      cell: {
        text: {
          type: 'number'
        }
      }
    },
    {
      title: '所属顾问',
      field: 'counselorName',
      minWidth: 150,
    },
    {
      title: '客户姓名',
      field: 'customerName',
      minWidth: 180,
    },
    {
      title: '提交人',
      field: 'createName',
      minWidth: 150,
    },
    {
      title: '提交日期',
      field: 'createTime',
      minWidth: 150,
      slots: {
        default: (params, h) => {
          return params.row.createTime ? params.row.createTime.split(' ')[0] : ''
        }
      }
    },
    {
      title: '审批状态',
      field: 'auditStateStr',
      minWidth: 150,
    },
    {
      title: '当前审批节点',
      field: 'nextChecker',
      minWidth: 180,
    },
    {
      title: '操作',
      fixed: 'right',
      width: 140,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'viewFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }, ]
  }

}


export default Column